<template>
	<div>
		<el-form size="mini"  label-width="200px">
			<el-form-item v-for="item in options" :key='item.key' :label='item.title'>
				<template v-if="item.type == 'input'">
					<el-input v-model="item.value"></el-input>
				</template>
				<template v-if="item.type == 'file'">
					<o-upload 
						:file-type='item.extra_json.file_type'
						v-model="item.value"></o-upload>
				</template>
				<template v-if="item.type == 'image'">
					<o-upload v-model="item.value"></o-upload>
				</template>
				<template v-if="item.type == 'content'">
					<oEditor v-model='item.value'></oEditor>
				</template>
			</el-form-item>
			<el-form-item>
				<el-button type='primary' @click='confirm'>保 存 设 置</el-button>
			</el-form-item>
		</el-form>
	</div>
	
</template>

<script>
	import {toast} from '@u'
	export default {
		components: {
			
		},
		props :{
			group : {
				type : String,
				default :''
			},
			isInline : {
				type : Boolean,
				default : false
			}
		},
		data () {
			return {
				options : [],
			}
		},
		created () {
			this.init();
		},
		
		methods : {
			init () {
				this.__api.common.getFromConfigByGroup({
					group : this.group
				}).then(res => {
					this.options = res;
				})
			},
			showDialog (item) {
				// console.log(this.$refs[item.key])
				this.$refs[item.key][0].show();
			},
			confirm () {
				this.__api.common.groupFormUpdate(this.options).then(_ => {
					toast('操作成功')
					this.init();
				})
			}
		},
	}
</script>
